﻿using System.Windows.Input;
using System.Windows;

namespace MDCAdminTool.Commands
{
    public class RemoveRegionCacheName : CommandBinding
    {
        public RemoveRegionCacheName()
        {
            Command = Application.Current.Resources["RemoveRegionCacheName"] as ICommand;
            CanExecute += OnCanExecute;
            Executed   += OnExecuted;
        }

        protected void OnExecuted( object sender , ExecutedRoutedEventArgs e )
        {
            var region = e.Parameter as CacheRegion;
            if ( region != null )
            {
                region.Parent.Remove( region );
            }
        }
        protected void OnCanExecute( object sender , CanExecuteRoutedEventArgs e )
        {
            e.CanExecute = true;
        }
    }
   
}
